<template>
    <div class="newsinfo-container">
        <h1 class="title">{{newsInfo.title}}</h1>
        <p class="subtitle">
            <span>发表时间:{{newsInfo.add_time | dataFormat}}</span>
            <span>点击:{{newsInfo.click}}次</span>
        </p>

        <hr>

        <div class="content" v-html="newsInfo.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui'
    import Comment from '../subcomponents/Comment.vue'

    export default{
        data(){
            return{
                id : this.$route.params.id,
                newsInfo : {}
            }
        },
        created(){
            this.getNewsinfo();
        },
        methods:{
            getNewsinfo(){
                /* this.$http.get(''+this.id).then(result => {
                    console.log(result.body);
                    if(result.body.status === 0){
                        this.newsInfo = result.body.message[0];
                    }else{
                        Toast('加载新闻信息失败。。。')
                    }
                }) */

               this.newsInfo = {"id":this.id,"title":"天气预报","click":23,"add_time":"2019-10-11 12:34:56","content":"今天天气真好啊<hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>哈哈哈哈哈<hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>嘿嘿<r><hr><hr><hr><hr><hr><hr><hr><hr><hr>嘿嘿<r><hr><hr><hr><hr><hr><hr><hr><hr><hr>嘿嘿<r><hr><hr><hr><hr><hr><hr><hr><hr><hr>嘿嘿"}
            }
        },
        components : {
            "comment-box" : Comment
        }
    }
</script>

<style lang="scss">
    .newsinfo-container{
        padding: 0 4px;

        .title{
            font-size: 16px;
            text-align: center;
            margin: 15px 0;
            color: red;
        }
        .subtitle{
             font-size: 13px;
             color: #226aff;
             display: flex;
             justify-content: space-between;
        }
        .content{
            img{
                width: 100%;//scoped 会影响到实际效果，所以这个<style>标签去掉了scoped属性
            }
        }
    }
</style>